<?php namespace sacvoyage;

function autoload($class_name, $file_extensions=null) {
	if(!$file_extensions) {
		$file_extensions=spl_autoload_extensions();
	}
	$extension_array=array_map('trim', explode(',',$file_extensions));
	
	
	if($class_name[0]=='\\' ) {
		$class_name=substr($class_name, 1);
	}
	foreach(explode(PATH_SEPARATOR, get_include_path()) as $path) {
		$base_dir=rtrim($path, DIRECTORY_SEPARATOR);
		foreach($extension_array as $extension) {
			$file_name=str_replace('\\', '/', $class_name).$extension;
			$full_name=$base_dir.DIRECTORY_SEPARATOR.$file_name;
			if(file_exists($full_name)) {
				require_once($full_name);
			}
		}
	}

	
}


?>
